/*
 * @Author       : wjw 3358953076@qq.com
 * @Date         : 2024-04-28 10:26:13
 * @LastEditors  : wjw 3358953076@qq.com
 * @LastEditTime : 2024-05-26 17:12:38
 * @FilePath     : \charger_controller\applications\bsp\include\bsp_can.h
 * @Description  : 
 * SPDX-License-Identifier: GPL-3.0
 * Copyright (c) 2024 by wjw, All Rights Reserved.
 */
#ifndef __BSP_CAN_H
#define __BSP_CAN_H

#define BSP_USING_CAN

#ifdef BSP_USING_CAN

#include <stdio.h>
#include <stdint.h>
#include <j1939.h>

//#define BSP_CAN2_EN
//#define BSP_CAN_RT_THREAD_DRV

//CAN设置接收回调函数最大个数
#define BSP_CAN_RX_CALLBSCKS_COUNT_MAX 4

#define BPS_CAN_500K 500//500K波特率
#define BPS_CAN_250K 250//250K波特率
#define BPS_CAN_125K 125//125K波特率

//CAN1过滤ID
#define CAN1_ID 		0x00003110
//CAN1过滤ID掩码
#define CAN1_IDMASK 	0x00000000
//CAN2过滤ID
#define CAN2_ID 		0x28AF002
//CAN2过滤ID掩码
#define CAN2_IDMASK 	0x00000000
//CAN1 波特率
#define CAN_1_BPS BPS_CAN_250K
//CAN2 波特率
#define CAN_2_BPS BPS_CAN_250K

typedef enum {
    can1_port,
    can2_port,
}Bsp_CAN_Port;

void bsp_can_init(Bsp_CAN_Port canx_port);
void bsp_can_start(Bsp_CAN_Port canx_port);
void bsp_can_stop(Bsp_CAN_Port canx_port);
int bsp_can_send_message(CAN_NODE canx_port,uint8_t *pbuf,uint32_t buf_len,uint32_t ExdID);
int bsp_can_add_rx_callback(CAN_NODE canx_port,void (*pCallbacks)(const uint32_t id, const uint8_t* buf, const uint32_t buf_len));

#endif
#endif // !__BSP_CAN_H
